<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
    <title>上传营业执照</title>  
</head>
<body>
<div class="ui segment" id="n-page">
        &nbsp;<br>
        &nbsp;<br>
        <h3 class="ui attached header" id="list-title">
            上传营业执照
        </h3>
        &nbsp;<br>
        &nbsp;<br>
我们需要对你提交的公司信息进行认证。&nbsp;<br>&nbsp;<br>
您必须提交公司的营业执照。&nbsp;<br>&nbsp;<br>
    <form class="ui form">
         <!--<div class="field">
            <label>您可以在这里上传公司营业执照</label>
            <div class="ui input">
                <input type="file" name="bizcodephoto" id="bizcodephoto" placeholder="请选择要上传的公司营业执照">
            </div>
        </div> -->
        <input type="hidden" name="hunterid" id="hunterid" value="${hunter.id}"/>
        <input type="hidden" name="companyId" id="companyId" value="${company.id}"/>
    </form>
 <%--       <c:choose>
           <c:when test="${hunter.imageUrl == null }">
              <img class=" floated mini ui image"  id="miniImg"
               src="${hunter.imageUrl}">
           </c:when>
       </c:choose>   --%>
</div>
<div class="ui segment" id="btn-next">
    <div class="fluid ui button" id="next">上传营业执照</div>
</div>

<!--
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
-->
<script src="${ctx}/resources/jweixin-1.0.0.js"></script>

<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<script src="${ctx}/resources/semanticui/semantic.js" type="text/javascript"></script>
<script type="text/javascript">

wx.config({
    debug: false, 
    appId: "${config.appid}",  
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'chooseImage',
        'previewImage',
        'uploadImage',
        'downloadImage',
        'closeWindow']  
});

    var url = '${ctx}/wechat/hunterCompany/uploadFile.do';
    var handler = { 
        activate: function() { 
            $(this).addClass('active').siblings().removeClass('active'); 

            if($(this).attr('id') == 'next') {
                $(this).addClass('disabled');
                wx.chooseImage({
                    count: 1,
                    success: function (res) {
                        var localId = res.localIds[0];
                        wx.uploadImage({ 
                            localId: localId,  
                            isShowProgressTips: 1,  
                            success: function (res) { 
                                var serverId = res.serverId;
                               /*  imageUrl=res.serverId;
                                $("#miniImg").attr("src",serverId); */
                                wx.downloadImage({
                                    serverId: res.serverId, // 需要下载的图片的服务器端ID，由uploadImage接口获得
                                    isShowProgressTips: 1, // 默认为1，显示进度提示
                                    success: function (res) {
                                        var localId = res.localId; // 返回图片下载后的本地ID
                                        //获取本地图片接口
                                        wx.getLocalImgData({
                                            localId: localId, // 图片的localID
                                            success: function (res) {
                                                var localData = res.localData; // localData是图片的base64数据，可以用img标签显示
                                            }
                                        });
                                    }
                                });
                                url += "?companyId=" + $('#companyId').val();
                                url += "&resId=" + serverId;
                                location.href = url;
                            } 
                        });
                    }
                });
            }
        } 
    };
 	
/*     var imageUrl; */
    $(document).ready(function() { 
        
        wx.ready(function(){
            $('.button').on('click', handler.activate);
        });

    });

</script>
</body>
</html>